//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.kun.portal.webframe.dao;

import com.kun.portal.webframe.po.FwRolePo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface FwRoleDao extends JpaRepository<FwRolePo, String>, JpaSpecificationExecutor<FwRolePo> {
    Page<FwRolePo> queryByCreatorAndRoleTypeAndRoleNameContainingOrderByRoleCode(String var1, String var2, String var3, Pageable var4);

    Page<FwRolePo> findByTeamIdContaining(String var1, Pageable var2);

    @Query("select p from FwRolePo p where p.roleCode like ?1 or p.roleName like ?1 ")
    Page<FwRolePo> findByKey(String var1, Pageable var2);

    @Query("select p from FwRolePo p where p.teamId like ?1 or p.teamId = '' or p.teamId is null ")
    Page<FwRolePo> queryRoleByTeam(String var1, Pageable var2);

    @Query("select p from FwRolePo p where (p.teamId like ?1 or p.teamId = '' or p.teamId is null) and (p.roleCode like ?2 or p.roleName like ?2 ) ")
    Page<FwRolePo> queryRoleByTeamAndKey(String var1, String var2, Pageable var3);

    @Query("select p from FwRolePo p where p.teamId like ?1")
    Page<FwRolePo> findByTeamIdLike(String var1, Pageable var2);

    @Query("select p from FwRolePo p where p.teamId like ?1 and (p.roleCode like ?2 or p.roleName like ?2 )")
    Page<FwRolePo> findByTeamIdLikeAndKey(String var1, String var2, Pageable var3);

    @Query("select p from FwRolePo p where p.teamId like ?1 and (p.roleCode like ?2 or p.roleName like ?2 ) ")
    Page<FwRolePo> findByTeamIdLikeAndKeyLike(String var1, String var2, Pageable var3);

    @Modifying
    @Query(
            value = "DELETE FROM fw_role_user WHERE role_id IN (SELECT role_id FROM fw_role WHERE team_id=?1)  AND user_id NOT IN (select user_id from fw_team_user where team_id=?1)",
            nativeQuery = true
    )
    void updateFwRoleUserByTeam(String var1);

    @Modifying
    @Query(
            value = "DELETE FROM fw_role_user WHERE user_id=?1",
            nativeQuery = true
    )
    void deleteFwRoleUserByUserId(String var1);

    @Modifying
    @Query(
            value = "DELETE FROM fw_role_user WHERE user_id=?1 and role_id=?2",
            nativeQuery = true
    )
    void deleteFwRoleUserByUserIdAndRoleId(String var1, String var2);
}
